package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.app.util.UserContext;
import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.ICommodityFormService;
import cn.wolfcode.trip.base.service.ICommodityService;
import cn.wolfcode.trip.base.util.JsonResult;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("commodityForm")
public class CommodityFormController {
    @Autowired
    private ICommodityFormService formService;

    @PostMapping
    public JsonResult save(Long commodityId){
        JsonResult result = new JsonResult();
        User user = UserContext.getCurrentUser();
        if (user == null){
            result.mark("请登录");
            return result;
        }
        try {
            formService.saveForm(commodityId,user);
        } catch (Exception e) {
            e.printStackTrace();
            result.mark(e.getMessage());
        }
        return result;
    }
}
